import java.lang.reflect.Array;
import java.util.Arrays;

public class testdome {
    public static void main1(String[] args) {
        int[] array=new int[]{1,2,3};
        fuc2(array);
        System.out.println(Arrays.toString(array));
    }
    //数组二倍
    public static void fuc(int[] array){
        for(int i=0;i< array.length;i++){
            array[i]*=2;
        }
    }
    //奇数在偶数前
    public static void fuc2(int[] array){
        int i=0;
        int j= array.length-1;
        while(i<j){
            while(i<j && array[i]%2!=0){
                i++;
            }
            while(i<j && array[j]%2==0){
                j--;
            }
            int temp=array[i];
            array[i]=array[j];
            array[j]=temp;
        }
    }
    //在数组中找到和为目标值的数组
    public static void main2(String[] args) {
        int[] array={3,4,5,6};
        int[] ret=fuc3(array,7);
        System.out.println(Arrays.toString(ret));
    }
    public static int[] fuc3(int[]num,int target){
        int[] ret={-1,-1};
        for (int i=0;i<num.length;i++){
            for(int j=i+1;j<num.length;j++){
               if(num[i]+num[j]==target) {
                   ret[0]=i;
                   ret[1]=j;
               }
            }
        }
        return ret;
    }
    //找只出现一次的数字 全^起来即可
    public static void main(String[] args) {
        int[] array={1,1,2};
        int ret=fuc4(array);
        System.out.println(ret);

    }
    public static int fuc4(int[]array) {
        int ret = 0;
        for (int i = 0; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }

}
